package com.whiteape.book.ui.adapter;

import android.graphics.Typeface;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseSectionQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.whiteape.book.R;
import com.whiteape.book.WaApp;
import com.whiteape.book.common.WaConstants;
import com.whiteape.book.model.zssq.section.BookListDetailSection;

import java.util.List;


public class RecommendChildAdapter extends BaseSectionQuickAdapter<BookListDetailSection, BaseViewHolder> {

    public RecommendChildAdapter(int layoutResId, int sectionHeadResId, List<BookListDetailSection> data) {
        super(layoutResId, sectionHeadResId, data);
    }

    @Override
    protected void convertHead(BaseViewHolder helper, BookListDetailSection item) {
        helper.setText(R.id.tv_recommend_header_title, item.header);
        helper.addOnClickListener(R.id.tv_recommend_header_more);
        TextView tvDetailList = helper.getView(R.id.tv_recommend_header_title);
        tvDetailList.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
        tvDetailList.getPaint().setFakeBoldText(true);


    }

    @Override
    protected void convert(BaseViewHolder helper, BookListDetailSection item) {
        Glide.with(mContext)
                .load(WaConstants.ZSSQ_IMG_BASE_URL + item.t.getCover())
                .placeholder(R.drawable.ic_default_portrait)
                .error(R.drawable.ic_load_error)
                .fitCenter()
                .into((ImageView)helper.getView(R.id.book_list_info_iv_cover));
        helper.setText(R.id.book_list_info_tv_title, item.t.getTitle());
        helper.setText(R.id.book_list_info_tv_desc, item.t.getLongIntro());
        helper.setText(R.id.book_list_info_tv_msg, item.t.getAuthor() + "| " + item.t.getMinorCate() + "| " + item.t.getWordCount()/10000 + "万字");
//        helper.setText(R.id.book_list_info_tv_msg, item.t);
//        helper.setText(R.id.book_brief_tv_msg, getContext().getResources().getString(R.string.booklist_message,
//                value.getBookCount(),value.getCollectorCount()));
        helper.addOnClickListener(R.id.recommend_book_detail);
    }

}
